package com.cysyz.mylib.jpadao;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import java.math.BigDecimal;

@Entity
@Table(name = "city_entity")
public class CityEntity {
    private String city;
    private int citypk;
    private String isend;
    private String mark;

    private BigDecimal money;

    private Double doubleMoney;

    private User user;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id")
    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @Id
    @Column(name = "citypk")
    public int getCitypk() {
        return citypk;
    }

    public void setCitypk(int citypk) {
        this.citypk = citypk;
    }

    @Basic
    @Column(name = "city")
    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    @Basic
    @Column(name = "isend")
    public String getIsend() {
        return isend;
    }

    public void setIsend(String isend) {
        this.isend = isend;
    }

    @Basic
    @Column(name = "mark")
    public String getMark() {
        return mark;
    }

    public void setMark(String mark) {
        this.mark = mark;
    }

    public BigDecimal getMoney() {
        return money;
    }

    @Column
    public void setMoney(BigDecimal money) {
        this.money = money;
    }

    public Double getDoubleMoney() {
        return doubleMoney;
    }

    @Column
    public void setDoubleMoney(Double doubleMoney) {
        this.doubleMoney = doubleMoney;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        CityEntity that = (CityEntity) o;

        if (citypk != that.citypk) return false;
        if (city != null ? !city.equals(that.city) : that.city != null) return false;
        if (isend != null ? !isend.equals(that.isend) : that.isend != null) return false;
        if (mark != null ? !mark.equals(that.mark) : that.mark != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = citypk;
        result = 31 * result + (city != null ? city.hashCode() : 0);
        result = 31 * result + (isend != null ? isend.hashCode() : 0);
        result = 31 * result + (mark != null ? mark.hashCode() : 0);
        return result;
    }


    @Override
    public String toString() {
        return "CityEntity{" +
                "city='" + city + '\'' +
                ", citypk=" + citypk +
                ", isend='" + isend + '\'' +
                ", mark='" + mark + '\'' +
                '}';
    }
}